package com.ruoyi.mode_specific.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mode_specific.domain.ModeSpecific;
import com.ruoyi.mode_specific.service.IModeSpecificService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author ruoyi
 * @date 2024-07-01
 */
@RestController
@RequestMapping("/mode_specific/mode_specific")
public class ModeSpecificController extends BaseController
{
    @Autowired
    private IModeSpecificService modeSpecificService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('mode_specific:mode_specific:list')")
    @GetMapping("/list")
    public TableDataInfo list(ModeSpecific modeSpecific)
    {
        startPage();
        List<ModeSpecific> list = modeSpecificService.selectModeSpecificList(modeSpecific);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('mode_specific:mode_specific:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ModeSpecific modeSpecific)
    {
        List<ModeSpecific> list = modeSpecificService.selectModeSpecificList(modeSpecific);
        ExcelUtil<ModeSpecific> util = new ExcelUtil<ModeSpecific>(ModeSpecific.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('mode_specific:mode_specific:query')")
    @GetMapping(value = "/{deviceSpecificId}")
    public AjaxResult getInfo(@PathVariable("deviceSpecificId") Long deviceSpecificId)
    {
        return AjaxResult.success(modeSpecificService.selectModeSpecificByDeviceSpecificId(deviceSpecificId));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('mode_specific:mode_specific:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ModeSpecific modeSpecific)
    {
        return toAjax(modeSpecificService.insertModeSpecific(modeSpecific));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('mode_specific:mode_specific:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ModeSpecific modeSpecific)
    {
        return toAjax(modeSpecificService.updateModeSpecific(modeSpecific));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('mode_specific:mode_specific:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{deviceSpecificIds}")
    public AjaxResult remove(@PathVariable Long[] deviceSpecificIds)
    {
        return toAjax(modeSpecificService.deleteModeSpecificByDeviceSpecificIds(deviceSpecificIds));
    }
}
